package com.tanhua.server.utils;


import com.tanhua.domain.db.User;
import com.tanhua.domain.mg.Comment;
import org.springframework.stereotype.Component;
@Component
public class ThreadLocalUtils {
    //定义一个ThreaLoad对象
    private ThreadLocal<User> threadLocal=new ThreadLocal<User>();

    //存入对象
    public void setUser(User user) {
        threadLocal.set(user);
    }

    //取出对象
    public User getUser() {
        return threadLocal.get();
    }
    //取出id
    public Long getUserId() {
        return threadLocal.get().getId();
    }
    //取出手机号
    public String getMobile() {
        return threadLocal.get().getMobile();
    }

}
